package com.example.result

import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.By
import androidx.test.uiautomator.Direction
import androidx.test.uiautomator.UiDevice
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class EveryTestTest {
    lateinit var device: UiDevice
    lateinit var context: Context

    @Before
    fun before() {
        val instrumentation = InstrumentationRegistry.getInstrumentation()
        context = instrumentation.targetContext
        device = UiDevice.getInstance(instrumentation)
        val packageName = context.packageName
//         context.startActivity(intent)
        val activityName = MainActivity::class.java.name
        device.launchActivity(packageName, activityName)
    }

    @Test
    fun everyDayGua() {
        val packageName = context.packageName
        device.findObject(By.scrollable(true)).swipe(Direction.RIGHT, 0.5f)
        val drawer = device.waitAndFindObject(By.desc("play dial"))!!
        device.takeScreenshot()
        drawer.click()
        device.waitForIdle(LAUNCH_TIMEOUT)
        device.waitAndFindObject(By.text("滚动到该卦"))!!.click()
        device.takeScreenshot()

    }


}